<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>Map Example</title>
		<script type="text/javascript">
			var em = null,
				map = null;
			// H5 plus事件处理
			function plusReady() {
				// 确保DOM解析完成
				if(!em || !window.plus || map) {
					return
				};
				map = new plus.maps.Map("map");
				map.centerAndZoom(new plus.maps.Point(116.3977, 39.906016), 12);
			}
			if(window.plus) {
				plusReady();
			} else {
				document.addEventListener("plusready", plusReady, false);
			}
			// DOMContentloaded事件处理
			document.addEventListener("DOMContentLoaded", function() {
				em = document.getElementById("map");
				plusReady();
			}, false);
			// 打开用户位置
			function showUserLocation() {
				map.showUserLocation(true);
			}
			// 关闭用户位置
			function hideUserLocation() {
				map.showUserLocation(false);
			}
			// 获取是否打开用户位置
			function isUserLocation() {
				alert(map.isShowUserLocation());
			}
		</script>
		<style type="text/css">
			#map {
				width: 100%;
				position: fixed;
				top: 100px;
				bottom: 0px;
				line-height: 200px;
				text-align: center;
				background: #FFFFFF;
			}
		</style>
	</head>

	<body>
		获取是否显示用户位置<br/>
		<button onclick="showUserLocation()">显示用户位置</button>
		<button onclick="hideUserLocation()">关闭用户位置</button><br/>
		<button onclick="isUserLocation()">是否显示用户位置</button>
		<div id="map">地图加载中...</div>
	</body>

</html>